/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.app.sessionBeans;

import com.app.entity.Log;
import com.app.entity.Usuario;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author EduardoAlexis
 */
@Stateless
public class LogFacade extends AbstractFacade<Log> {
    @PersistenceContext(unitName = "08092014FinalPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public LogFacade() {
        super(Log.class);
    }
    
      public List<Log> getLogUsuario(Usuario usuario){
   
   List<Log> lista;      
        try {
         lista = (List<Log>) getEntityManager().createQuery("Select l From Log l WHERE l.idUsuario = ?1")
                                                         .setParameter(1,usuario)
                                                         .getResultList();
      //SimpleDateFormat formatoDelTexto1 = new SimpleDateFormat("dd/MM/yyyy",new Locale("es", "ES"));
    //   SimpleDateFormat formatoDelTexto2 = new SimpleDateFormat("hh:mm:ss");
       
       for (Log lista1 : lista) {
           java.sql.Date sqlDate = new java.sql.Date(lista1.getFecha().getTime());
           lista1.setFecha(sqlDate);
         
       }   
       
      
            
            
            } catch (Exception e) {
        lista = null;
        }
          return lista;
    }
}
